DevForce Help Reference
ExecuteQueryAsync(EntityManager,IEntityQuery,Action<EntityQueryOperation>,Object) Method
Example 


EntityManager
The IdeaBlade.EntityModel.IEntityQuery to execute
Callback invoked when the query completes
Token to identify the query upon completion
Execute a query asynchronously.
Syntax
'Declaration
 
<ExtensionAttribute()>
Public Overloads Shared Function ExecuteQueryAsync( _
   ByVal em As EntityManager, _
   ByVal query As IEntityQuery, _
   ByVal userCallback As Action(Of EntityQueryOperation), _
   Optional ByVal userState As Object _
) As EntityQueryOperation
'Usage
 
Dim em As EntityManager
Dim query As IEntityQuery
Dim userCallback As Action(Of EntityQueryOperation)
Dim userState As Object
Dim value As EntityQueryOperation
 
value = EntityManagerAsyncExtensions.ExecuteQueryAsync(em, query, userCallback, userState)

Parameters

em
EntityManager
query
The IdeaBlade.EntityModel.IEntityQuery to execute
userCallback
Callback invoked when the query completes
userState
Token to identify the query upon completion
Remarks
Provide a userCallback if you want to be notified when the operation completes. The query results will be returned in the IdeaBlade.EntityModel.EntityQueriedEventArgs passed to the userCallback. Use the userState to uniquely identify this call. You can cancel a pending asynchronous call using IdeaBlade.EntityModel.BaseOperation<TEventArgs,TOp>.Cancel method.
Example
private void SampleAsynchQuery() {
  DomainModelEntityManager mgr = new DomainModelEntityManager();

  // Build a query and ask mgr to run it asynchronously.
  var query = mgr.Customers.Where(c => c.CompanyName.StartsWith("C"));
  int token = 1;
  mgr.ExecuteQueryAsync(query, AsyncQueryCompleted, token);
}

void AsyncQueryCompleted(EntityQueryOperation<Customer> e) {
  if (e.Error != null) {
    System.Diagnostics.Debug.WriteLine(e.Error.Message);
    return;
  }
  System.Diagnostics.Debug.WriteLine("queryid = " + e.UserState.ToString());
  System.Diagnostics.Debug.WriteLine("customers retrieved = " + e.Results.Count().ToString());
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EntityManagerAsyncExtensions Class
EntityManagerAsyncExtensions Members
Overload List

Send Feedback